//
//  MKTChatMsgMultiItemTVCellOther.m
//  MKUITestApp
//
//  Created by 苏尚进 on 2021/7/9.
//  Copyright © 2021 moon. All rights reserved.
//

#import "MKTChatMsgMultiItemTVCellOther.h"
#import "MKTChatItemTVCellBase.h"

@implementation MKTChatMsgMultiItemTVCellOther
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.itemsView = [[MKTChatItemsView alloc] init];
        
        self.itemsView.layer.cornerRadius = 10;
        self.itemsView.clipsToBounds = YES;
        self.itemsView.layer.borderColor = [UIColor grayColor].CGColor;
        self.itemsView.layer.borderWidth = 1;
        
        [self.contentView addSubview:self.itemsView];
        //
        MKUIFlowLayoutConstraint *f1 = [[MKUIFlowLayoutConstraint alloc] initWithItems:@[self.msgTextBubbleView,self.itemsView] constraintParam:(MKUIFlowLayoutConstraintParam_V_T_L) contentInsets:UIEdgeInsetsZero interitemSpacing:10];
        //
        self.flowlayout = [[MKUIFlowLayoutConstraint alloc] initWithItems:@[self.msgUserPicView,f1] constraintParam:(MKUIFlowLayoutConstraintParam_H_T_L) contentInsets:self.msgTextBubbleLayout.contentInsets interitemSpacing:self.msgTextBubbleLayout.interitemSpacing];
    }
    return self;
}
- (void)customLayoutSubviews{
    [super customLayoutSubviews];
    CGRect bounds = self.contentView.bounds;
    self.flowlayout.bounds = bounds;
    [self.flowlayout layoutItemsWithResizeItems:YES];
}
- (void)customReloadCellModel{
    [super customReloadCellModel];
    MKTChatMsgMultiItem *msg = self.chatMsg;
    self.msgTextBubbleView.textLabel.text = msg.title;
    self.itemsView.itemslist = msg.itemslist;
    [self.itemsView reloadData];
}
- (CGSize)customSizeThatFits:(CGSize)size{
    return [self.flowlayout sizeThatFits:size resizeItems:YES];
}
@end
